package com.du.back1.exception;


import com.du.back1.utills.BaseResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice("com.du.back1.controller")
public class GlobalException {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public BaseResult error(Exception e) {
        e.printStackTrace();
        return BaseResult.error();
    }

    @ExceptionHandler(CustomException.class)
    @ResponseBody
    public BaseResult customError(CustomException e) {
        e.printStackTrace();
        return BaseResult.error(e.getMessage(),e.getCode());
    }

}
